#include<bits/stdc++.h>
using namespace std;
int num,detector,len,limit,p[100005];
int closed[100005],visited[100005];
int cnt=0;
struct car{
    int d,vel,acc;
}c[100005];
double current(int xx,int yy,int z){  //xx means initial, yy means acc, z means position
    double velocity;
    velocity=pow(pow(xx,2)+2*yy*z,0.5);
    return velocity;
}

void judge(double xx,int yy,int z,int j){  //xx means velocity, yy means limit
    bool flag=true;
    if (xx>yy){
        if (!visited[j]){
            cnt++;
            visited[j]=1;
            flag=false;
        }
    }
    if (flag){
        closed[z]=1;
    }
    else{
        closed[z]=0;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++){
        cnt=0;
        memset(closed,0,sizeof(closed));
        memset(visited,0,sizeof(visited));
        cin>>num>>detector>>len>>limit;
        for(int j=1;j<=num;j++){
            cin>>c[j].d>>c[j].vel>>c[j].acc;
        }
        for(int j=1;j<=detector;j++){
            cin>>p[j];
        }
        for(int j=1;j<=num;j++){
            for(int k=1;k<=detector;k++){
                double x=current(c[j].vel,c[j].acc,p[k]);
                judge(x,limit,k,j);
            }
        }
        int number=0;
        for(int j=1;j<=detector;j++){
            if (closed[j]){
                number++;
            }
        }
        cout<<cnt<<" "<<number<<endl;
    }

    fclose(stdin);
    fclose(stdout);
return 0;
}
